#!/bin/bash
SVNSERVER=$1
PROJECT=$2
FOLDER=$3
VERSION=$4
OPERATOR=$5
echo build normal ant bxn project
echo server:$SVNSERVER project:$PROJECT
echo folder:$FOLDER version:$VERSION
CURRENTTIME=$6
TODAY=$(date +%Y%m%d)
echo timestamp:$CURRENTTIME 
BASE=/tmp/package/$PROJECT-$CURRENTTIME
echo base:$BASE
rm -rf $BASE
export LC_CTYPE=en_US.UTF-8
svn export svn://$SVNSERVER/$PROJECT/$FOLDER/$VERSION $BASE --username tiger --password svn555666
cd $BASE
touch build.properties
echo version=${VERSION} >>build.properties
echo operator=${OPERATOR} >>build.properties
echo project=${PROJECT} >>build.properties

touch build.xml
cat /usr/svntools/antscript/build_1.xml >> build.xml
libs=$(ls WebContent/WEB-INF/lib)
for lib in $libs
do
echo '<pathelement path="WebContent/WEB-INF/lib/'$lib'" />' >> build.xml
done
cat /usr/svntools/antscript/build_2.xml >> build.xml
ant build
cp $BASE/$PROJECT-$VERSION.war /opt/build/$TODAY/$PROJECT-$VERSION-$CURRENTTIME.war
cd ..
rm -rf $BASE
